home *** CD-ROM | disk | FTP | other *** search
- Path: watnews.watson.ibm.com!ncohen
- From: ncohen@watson.ibm.com (Norman H. Cohen)
- Newsgroups: comp.lang.ada,comp.lang.c++
- Subject: Re: on OO differnces between Ada95 and C++
- Date: 28 Feb 1996 20:59:22 GMT
- Organization: IBM T.J. Watson Research Center
- Distribution: world
- Message-ID: <4h2fna$hp6@watnews1.watson.ibm.com>
- References: <4gbq7q$g08@qualcomm.com> <4gdidj$10f5@watnews1.watson.ibm.com> <4gveoa$nnd@mulgave.octacon.co.uk>
- Reply-To: ncohen@watson.ibm.com
- NNTP-Posting-Host: rios8.watson.ibm.com
-
- In article <4gveoa$nnd@mulgave.octacon.co.uk>,
- Adam.Morris@octacon.co.uk (Adam Morris) writes:
-
- |> In article <4gdidj$10f5@watnews1.watson.ibm.com>,
- |> ncohen@watson.ibm.com (Norman H. Cohen) wrote:
- ...
- |> In C and C++
- |> >importing is transitive--if B #includes A and C #includes B, then C has
- |> >effectively #included A--while in Ada it is not--if B has a with clause for
- |> >A and C has a with clause for B, then A is not visible in C unless C has
- |> >its own explicit with clause for A.
- |>
- |> Only if you do what you shouldn't do... the .h file should have forward
- |> declarations of all classes it uses except in certain cases. And what are
- |> those cases, if A inherits from B then (and only then as far as I know) should
- |> you #include B.h in A.h otherwise you have a declaration saying
- |> class B{};
-
- Yes, but A.H must include B.H even if A inherits from B as a PRIVATE base
- class. In that case the interface of class B should not in any way be
- considered part of the interface of class A, but any file that #includes
- A gets gratuitous access to the entities declared in B.H. This does not
- happen in Ada. The Ada equivalent is
-
- with B_Package;
- package A_Package is
- type A_Type is tagged private;
- ...
- private
- type A_Type is new B_Package.B_Type with ...;
- ...
- end A_Package;
-
- A package that has a with clause for A_Package, but not for B_Package,
- does not get access to B_Package.
-
- The issue arises not only for inheritance, but also for composition.
- If A has a private member of class B, A.H must #include B.H. Again, the
- interface of class B is not logically part of the interface for class A,
- but you can't #include A.H without also #including B.H. The Ada
- equivalent is
-
- with B_Package;
- package A_Package is
- type A_Type is tagged private;
- ...
- private
- type A_Type is tagged
- record
- ...
- Some_Component: B_Package.B_Type;
- ...
- end record;
- ...
- end A_Package;
-
- and once again, a package that has a with clause for A_Package, but not
- for B_Package, does not get access to B_Package.
-
- --
- Norman H. Cohen ncohen@watson.ibm.com
-